package com.example.event_resource_java.authority.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.event_resource_java.authority.dao.EventResourceAllocationDO;
import com.example.event_resource_java.authority.dao.EventResourceAllocationsDO;
import com.example.event_resource_java.authority.dao.ModuleDao;
import com.example.event_resource_java.authority.dao.PaperDao.*;
import com.example.event_resource_java.commons.vo.HomeSearchVO;
import com.example.event_resource_java.commons.vo.TitleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface ResourceMapper extends BaseMapper<EventResourceAllocationsDO> {

    /**
     * 首页搜索
     */
    List<HomeSearchVO> getHomeSearch(String searchValue);

    List<String> getHeadLineTitle();

    /**
     * 获取模板列表
     */
    List<ModuleDao> getModuleList();

    /**
     * 获取所有赛项资源 时间倒序
     */
    List<EventResourceAllocationDO> getAllocationList();

    /**
     * 获取赛项资源查询参数
     */
    List<EventResourceAllocationDO> getEventTitle(Long JzEveMoId);

    List<TitleVO> getAllocationTitleList();

    /**
     * 获取赛项资源子模块资源列表
     */
    List<EventResourceAllocationDO> getMatchResourceList(String eventName, Integer type, String time, Long eveMoId, Integer grade);

    /**
     * 获取赛项资源子模块资源详情
     */
    List<EventResourceAllocationsDO> getMatchResourceDetails(Long id);

    List<EventResourceAllocationsDO> getMatchResourceByParentId(Long parenId);

    /**
     * 更新赛项资源子模块资源学习人次
     */
    boolean updateNumStu(Long id);

    /**
     * 根据模板id获取赛项资源子模块资源
     */
    EventResourceAllocationDO getAllocationsByMoId(Long id);

    /**
     * 根据id获取赛项资源
     */
    EventResourceAllocationDO getAllocationById(Long id);

    /**
     * 获取考试某一类型试题
     */
    List<ItemBankDO> getExamination(@Param("profileId") Long profileId, @Param("grade") String grade, @Param("itemBankType") Integer itemBankType,
                                    @Param("type") Integer type, @Param("topicTypes") Integer topicTypes, @Param("itemNum") Integer itemNum);



    List<ItemBankDO> getItemList(@Param("kpointsId") Long kpointsId, @Param("itemBankType") Integer itemBankType,
                                    @Param("type") Integer type, @Param("topicTypes") Integer topicTypes, @Param("itemNum") Integer itemNum);
    /**
     * 获取试卷模板详情
     */
    List<TemplateDetailsDO> getTemplateDetail(Long templateId, Integer paperTemplateType);

    /**
     * 获取证书信息
     */
    CertificateNewsDO getCertificateNews(Long templateId);

    /**
     * 获取知识点列表
     */
    public List<Long> getKnowledgeId(Long profileId, String grade);

    /**
     * 获取赛项资源理论题库的试卷
     */
    List<ExaminationListDO> getExaminationList(Long profileId);

    /**
     * 获取试卷模板信息
     */
    TestPaperTemplateDO getTestPaperTemplateDetail(Long templateId);

    /**
     * 获取单个考试题目
     */
    ItemPaperDao questionDetail(Long id);

    /**
     * 交卷时保存练习记录
     */
    Long savePracticeRecord(@Param("e") EventResourcePracticeRecordDO eventResourcePracticeRecordDO);

    /**
     * 判断是否存在练习记录
     */
    Long isExistRecord(Long userId, Long paperId, Integer level, Long allocationId);

    Long isExistCaseRecord(Long userId, String paperTitle);

    Long isExistNotDoneRecord(Long userId, Long paperId);


    /**
     * 更新练习记录
     */
    boolean updatePracticeRecord(@Param("p") PracticeRecordDO practiceRecordDO,
                                 @Param("practiceId") Long practiceId);

    boolean updateCasePracticeRecord(String latestPracticeTime ,Long practiceId);

    boolean updatePracticeRecordDoNothing(@Param("p") PracticeRecordDO practiceRecordDO,
                                  @Param("practiceId") Long practiceId);

    /**
     * 获取练习记录
     */
    PracticeRecordDO getContinuePracticeRecord(Long practiceRecordId);

    /**
     * 获取所有赛项资源
     * @return
     */
    List<EventResourceAllocationDO> evens();

}
